<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<script type="text/javascript">
	//添加资源管理
	function resourceAdd() {
		$("#resource_add").form("submit", {
			url : '${pageContext.request.contextPath}/resourceController/addResource',
			onSubmit : function() {
				var isValid = $(this).form('validate');
				if (!isValid) {
					$.messager.alert("提示", "保存失败！");
					$.messager.progress('close'); // 如果表单是无效的则隐藏进度条
				}
				return isValid; // 返回false终止表单提交
			},
			success : function(data) {
				 var obj = $.parseJSON(data);
				 if(obj.success){
	  					$.messager.alert('提示','保存成功','info');
	  				}else{
	  					$.messager.alert('提示',obj.msg,'error');
	  				}
				$.messager.progress('close'); // 如果提交成功则隐藏进度条
				$("#ResourceWindow").window('close');
				$("#treeGrid").treegrid("reload");//重新加载datagrid
			}
		});
	}
	
</script>

<div id="ResourceWindow" class="easyui-window"
	data-options="modal:true,closed:true,collapsible:false,minimizable:false"
	style="width: 600px; height: 400px; padding: 10px;">
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center'"
			style="text-align: center; padding: 10px;">
			<form id="resource_add" name="form" method="post">
				<table cellpadding="7" cellspacing="2" align="center">
				<tr>
					<th>编 &nbsp;&nbsp;&nbsp;号</th>
					<td><input name="id" type="text" class="easyui-validatebox" >
					</td>
					<th>资源名称</th>
					<td><input name="name" type="text" placeholder="请输入资源名称" class="easyui-validatebox span2" data-options="required:true"></td>
				</tr>
				
				<tr>
					<th>资源路径</th>
					<td><input name="url" type="text" placeholder="请输入资源路径" class="easyui-validatebox span2" ></td>
					<th>资源类型</th>
					<td><select id="typeId" class="easyui-combobox" name="resourceTypeId"
								data-options="required:true,
											width:155,height:29,
											url:'<%=request.getContextPath()%>/resourceController/getResourceType',
											method:'post',
											valueField:'id',
											textField:'name',
											panelHeight:'auto'">
							</select></td>
				</tr>
		
				<tr>
					<th>排序</th>
					<td><input name="seq" value="100" class="easyui-numberspinner" style="width: 155px; height: 29px;" required="required" data-options="editable:true,min:100"></td>
					<th>上级资源</th>
					<td><select id="pid" class="easyui-combobox" name="pid"
								data-options="required:true,
											width:155,height:29,
											url:'<%=request.getContextPath() %>/resourceController/getParentResource',
											method:'post',
											valueField:'id',
											textField:'name',
											panelHeight:'auto'">
							</select>
							</td>
				</tr>
				<tr>
					<th>菜单图标</th>
					<td colspan="3"><input id="iconCls" name="iconCls" style="width: 375px; height: 29px;" data-options="editable:false" /></td>
				</tr>
				<tr>
					<th>备注</th>
					<td colspan="3"><textarea name="remark" rows="2" cols="43" class="span5"></textarea></td>
				</tr>
			</table>
			</form>
		</div>
		<div data-options="region:'south',border:false"
			style="text-align: right; padding: 5px 0 0;">
			<a data-options="iconCls:'icon-ok'" href="javascript:void(0)"
				class="easyui-linkbutton" onclick="resourceAdd();">提交</a> <a
				href="javascript:void(0)" data-options="iconCls:'icon-cancel'"
				class="easyui-linkbutton"
				onclick="$('#resource_add').form('clear')">重置</a> <a
				href="javascript:void(0)" data-options="iconCls:'icon-no'"
				class="easyui-linkbutton" onclick="$('#ResourceWindow').window('close')">关闭</a>
		</div>

	</div>
</div>